<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link href="/static/static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="/static/static/h-ui.admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="/static/lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script><![endif]-->
<title>添加合租信息</title>
<style type="text/css">
td{position: relative;}
.msg{top: -14px;left: 50px;display: block;height: 25px;width: 52px;padding: 0;text-align: center;line-height: 25px;cursor: auto;position: absolute;font-size: 12px;z-index: 20;color: #fff;background: #f36;box-shadow: 0 3px 8px 0 rgba(255,50,101,.3);border-radius: 2px;}
.msg::after{content: "";display: inline-block;border-width: 7px 6px;border-style: solid;border-color: #f36 transparent transparent;position: absolute;top: 25px;left: 20px;}
</style>
</head>
<body>
<div class="mt-20">
    <table class="table table-border table-bordered table-bg table-hover table-sort">
      <thead>
        <tr class="text-c">
          <th width="30">合租房id</th>
          <th width="30">房间号</th>
          <th width="40">面积</th>
          <th width='30'>朝向</th>
          <th width='30'>特色</th>
          <th width='30'>租客</th>
          <th width='30'>价格</th>
          <th width='20'>出租状态</th>
          <th width='30'>操作</th>
        </tr>
      </thead>
      <tbody>
      {foreach name='data' item='v'}
        <tr class="text-c va-m you">
          <td>{if condition='$v.hid == $id'}<p class='msg'>本房间</p>{/if}{$v.hid}</td>
          <td>{$v.num}</td>
          <td>{$v.mian}</td>
          <td>{$v.face}</td>
          <td>{$v.tese}</td>
          <td>{if condition='$v.tel'} {$v.tel} {else} <form action="" method='post'><input type="text" class="input-text" name="tel" placeholder="手机号" required>{/if}</td>
          <td>{$v.price}</td>
          <td>{$v.status}</td>
          <td>
            <a style="text-decoration:none" onClick="chuzu(this,'{$v.hid}')" title='租房/交房' target='_blank'><i class="glyphicon glyphicon-arrow-up">{if condition='$v.status == "已租"'}交房{else}出租{/if}</i></a></form>
            <a style="text-decoration:none" class="ml-5" onClick="product_del(this,'{$v.hid}')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
        </tr>
        {/foreach}
      </tbody>
    </table>
  </div>
{include file='public/footer'}
<script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
  <script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript">
  $().ready(function(){
    $('form').validate({
      submitHandler:function(form){
        $(form).ajaxSubmit({
          type:'post',
          url:'{:url('hezu_add')}?rid={:input('get.rid')}',
          dataType:'text',
          success:function(res){
            res = eval('('+res+')');
            layer.msg(res.msg,{icon: 1,time:1000},function(){
              location.reload();
            });
          }
        })
      }
    });
  })


  //删除合租房
function product_del(obj,id){
  layer.confirm('确认要删除吗？',function(index){
    $.post('hezu_del.html','hid='+id,function(res){
      $(obj).parents("tr").remove();
      layer.msg('已删除!',{icon:1,time:1000});
    })
  });
}
//出租
function chuzu(obj,id){
  if($(obj).children().text() == '已租'){
    layer.confirm('确认要收回房子吗？',function(index){
      var tel = $(obj).parent().prev().prev().prev().children().children().val();
      $.post('chuzu.html','hid='+id+'&&tel='+tel,function(res){
        layer.msg(res.msg,{icon:1,time:1000},function(){
          location.reload();
        });
      })
    });
  }else{
    layer.confirm('确认要出租房子吗？',function(index){
      var tel = $(obj).parent().prev().prev().prev().children().children().val();
      $.post('chuzu.html','hid='+id+'&&tel='+tel,function(res){
        layer.msg(res.msg,{icon:1,time:1000},function(){
          location.reload();
        });
      })
    });
  }
}
</script>